/**
 * Created by billy on 2017/4/25.
 */
var g = require("nodeLib");
var _file = g.data.file.get("user");
var _sql;

module.exports = class {
	constructor()
	{
		_file.add(__projpath("./module/sql/user"));
		_sql = g.data.manager.getManager("bluewoniu");
		this.add("test", this.test);

	}

	test($data, $success, $error, $client)
	{
		var txtContent = g.fs.readFileSync(__projpath("assets/a")).toString();
		var rowArr = txtContent.split("\r\n");
		var list = []
		for (var i = 0; i < rowArr.length; i++)
		{
			var itemList = rowArr[i].split("\t");
			if (itemList[0].length > 0)
			{
				list.push(itemList[0])
			}
		}
		var sqlStr = ""
		for (var key in list)
		{
			sqlStr += _file.get("updateBase_form_item.sql", {
				formId: 7,
				target: list[key],
				itemId: ++key
			})
		}
		_sql.query(sqlStr, ($res) => {
			$success("")
		})
//		trace(sqlStr);
////		g.fs.writeFileSync(__projpath("sql.json"), JSON.stringify(sqlStr));
//		trace("ALL DONE!");
//		process.exit();
	}
}